package com.itheima.dao;


import com.itheima.domain.Manager;
import com.itheima.utils.JDBCUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

/*
    操作数据库的类
* */
public class ManagerDao {
    //创建一个JDBCTempt对象
    private JdbcTemplate template =new JdbcTemplate(JDBCUtils.getDataSourse());
    public Manager login(Manager manager){
        String s ="select * from manager where username=? and password=?";
        Manager m =null;
        try {
            m = template.queryForObject(s, new BeanPropertyRowMapper<>(Manager.class), manager.getUsername(), manager.getPassword());
        } catch (DataAccessException e) {
            e.printStackTrace();
        }
        return m;
    }
}



